package com.person.leetcode.editor.cn;

/**
  * 70.爬楼梯
  * 2022-04-20 09:51:17
**/
public class Sequence_0070_ClimbingStairs {
    public static void main(String[] args) {
        Solution solution = new Sequence_0070_ClimbingStairs().new Solution();
    }
    //leetcode submit region begin(Prohibit modification and deletion)
class Solution {
    public int climbStairs(int n) {
        //fn = fn1 + fn2
        //递归超时
        int fn2 = 1;
        int fn1 = 2;
        int fn = 0;
        if (n <3){
            return n;
        }else{
            for (int i=3;i<=n;i++){
                fn = fn1 + fn2;
                fn2 = fn1;
                fn1 = fn;
            }
            return fn;
        }
    }
}
//leetcode submit region end(Prohibit modification and deletion)

}
